package com.lmf.cloud.springbootkafka.controller;

import jakarta.annotation.Resource;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description TODO
 * @Author LiuMingFu
 * @Date 2024/8/11 10:47
 */
@RequestMapping("/kafka")
@RestController
public class KafkaProducerController {

    //注入kafkaTemplate
    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;


    @RequestMapping("/sendMessage")
    public String sendMessage(@RequestParam String message) {
        kafkaTemplate.send("depart", "springboot-kafka", "测试-" + message);
        return "success";
    }

}
